#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
	int arr[100] = { 0 }; int n = 0;
	while (scanf("%d", &n) == 1 && n != 0)
	{
		int i = 0; int j = 0; int tmp = 0;
		for (i = 0; i < n; i++)
		{
			scanf("%d", &arr[i]);
		}
		for (i = 0; i < n - 1; i++)
		{
			for (j = 0; j < n - 1; j++)
			{
				if (arr[j] >= 0 && arr[j + 1] >= 0 && arr[j] < arr[j + 1])
				{
					tmp = 0; tmp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = tmp;
				}
				else if (arr[j] <= 0 && arr[j + 1]<=0 && abs(arr[j])<abs(arr[j + 1]))
				{
					tmp = 0; tmp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = tmp;
				}
				else if ((arr[j] < 0 || arr[j + 1] < 0) && abs(arr[j]) < abs(arr[j + 1]))
				{
					tmp = 0; tmp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = tmp;
				}
			}
		}
		for (i = 0; i < n; i++)
		{
			printf("%d ", arr[i]);
		}
		printf("\n");
	}

	return 0;
}

